package com.kaifa.api;
import java.util.Random;
import java.util.Scanner;

public class CommonApi {

    public String toString(String str) {
        return "小" + str;
    }
    public String toString(String str,String str1){
        return str+"和"+str1;
    }

    /**
     * 九九乘法表
     * @param num 参数
     */
    public void jiujiu(int num){
        for(int a = 1;a<=num;a++){
            for(int b=1;b<=a;b++){
                if(a == b){
                    System.out.println(b+"*"+a+"="+a*b);
                }else{
                    System.out.print(b+"*"+a+"="+a*b+",");
                }
            }
        }
    }

    /**
     * 猜数字
     * @param ss 随机数范围
     * @param a
     * @param b
     */
    public void jiujiu(int ss,int a,int b){
        System.out.println("请输入你要猜测的数值：");
        Random ran = new Random();
        int num = ran.nextInt(ss);
        Scanner scan = new Scanner(System.in);
        for(int i = a;i>=b;i--){
            int num2 = scan.nextInt();
            if(num>num2){
                System.out.println("猜小了");
            }else if(num<num2){
                System.out.println("猜大了");
            }else{
                System.out.println("猜对了");
                System.exit(0);
            }
        }
        System.out.println("机会用尽，正确值为："+num);
        scan.close();
        System.exit(0);
    }
    public static void main(String[] args) {
        CommonApi ca = new CommonApi();
        String str = ca.toString("猫");
//        System.out.println(str);
        String stt = ca.toString("小猫","小狗");
//        System.out.println(stt);

        int ss = 9;
        ca.jiujiu(ss);
        ca.jiujiu(300,5,1);
        ca.jiujiu(200,5,1);
        ca.jiujiu(100,5,1);





    }


}
